package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Destroy {
    private int destroyId;
    private Long destroyAllquantity;
    private Timestamp destroyTime;
    private String destroyState;
    private String destroyReason;
    private String destroyHead;
    private Collection<DestryDetails> destryDetailsByDestroyId;

    @Id
    @Column(name = "destroy_id", nullable = false)
    public int getDestroyId() {
        return destroyId;
    }

    public void setDestroyId(int destroyId) {
        this.destroyId = destroyId;
    }

    @Basic
    @Column(name = "destroy_allquantity", nullable = true, precision = 0)
    public Long getDestroyAllquantity() {
        return destroyAllquantity;
    }

    public void setDestroyAllquantity(Long destroyAllquantity) {
        this.destroyAllquantity = destroyAllquantity;
    }

    @Basic
    @Column(name = "destroy_time", nullable = true)
    public Timestamp getDestroyTime() {
        return destroyTime;
    }

    public void setDestroyTime(Timestamp destroyTime) {
        this.destroyTime = destroyTime;
    }

    @Basic
    @Column(name = "destroy_state", nullable = true, length = 20)
    public String getDestroyState() {
        return destroyState;
    }

    public void setDestroyState(String destroyState) {
        this.destroyState = destroyState;
    }

    @Basic
    @Column(name = "destroy_reason", nullable = true, length = 30)
    public String getDestroyReason() {
        return destroyReason;
    }

    public void setDestroyReason(String destroyReason) {
        this.destroyReason = destroyReason;
    }

    @Basic
    @Column(name = "destroy_head", nullable = true, length = 30)
    public String getDestroyHead() {
        return destroyHead;
    }

    public void setDestroyHead(String destroyHead) {
        this.destroyHead = destroyHead;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Destroy destroy = (Destroy) o;
        return destroyId == destroy.destroyId &&
                Objects.equals(destroyAllquantity, destroy.destroyAllquantity) &&
                Objects.equals(destroyTime, destroy.destroyTime) &&
                Objects.equals(destroyState, destroy.destroyState) &&
                Objects.equals(destroyReason, destroy.destroyReason) &&
                Objects.equals(destroyHead, destroy.destroyHead);
    }

    @Override
    public int hashCode() {
        return Objects.hash(destroyId, destroyAllquantity, destroyTime, destroyState, destroyReason, destroyHead);
    }

    @OneToMany(mappedBy = "destroyByDestroyId")
    public Collection<DestryDetails> getDestryDetailsByDestroyId() {
        return destryDetailsByDestroyId;
    }

    public void setDestryDetailsByDestroyId(Collection<DestryDetails> destryDetailsByDestroyId) {
        this.destryDetailsByDestroyId = destryDetailsByDestroyId;
    }
}
